package com.md.model.word;

import com.md.value.html.TextAlign;
import lombok.Data;
import org.apache.poi.ss.usermodel.FontUnderline;
import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
import org.apache.poi.xwpf.usermodel.TextAlignment;

import java.util.List;

/**
 * @author 刘骄阳
 * 2024-05-18 1:30
 */
@Data
public class ParagraphStyleInfo {

  /**
   * 字体颜色
   */
  private String color;
  /**
   * 字体大小
   */
  private Double fontSize;

  /**
   * 字体名称
   */
  private String fontName;

  /**
   * 下划线
   */
  private FontUnderline underline;
  /**
   * 是否倾斜
   */
  private Boolean isItalic;
  /**
   * 是否加粗
   */
  private Boolean isBold;

  /**
   * 是否有删除线
   */
  private Boolean isStrikeOut;

  /**
   * 纯文本内容
   */
  private String content;

  /**
   * (段落)对齐方式
   */
  private ParagraphAlignment paragraphAlignment;

  /**
   * 文本对齐方式
   */
  private String fontAlignment;

  /**
   * 垂直对齐方式
   */
  private TextAlignment verticalAlignment;

  /**
   * 段落文本样式
   */
  private List<ParagraphFontStyleInfo> fontStyles;

  public TextAlign getVerticalAlign() {
    if (paragraphAlignment == null) {
      return null;
    }
    switch (paragraphAlignment) {
      case LEFT:
        return TextAlign.LEFT;
      case BOTH:
        return TextAlign.JUSTIFY;
      case RIGHT:
        return TextAlign.RIGHT;
      case CENTER:
        return TextAlign.CENTER;
      default:
        break;
    }
    return TextAlign.LEFT;
  }
}
